misc
Class Queue

java.lang.Object
  extended by misc.Queue

public class Queue
extends java.lang.Object

Array-based implementation of the queue.

Author:
Mark Allen Weiss

Constructor Summary
Queue()
          Construct the queue.
Queue(int size)
          Construct the queue.
 
Method Summary
 java.lang.Double dequeue()
          Return and remove the least recently inserted item from the queue.
 void enqueue(java.lang.Double x)
          Insert a new item into the queue.
 java.lang.Double getFront()
          Get the least recently inserted item in the queue.
 boolean isEmpty()
          Test if the queue is logically empty.
 void makeEmpty()
          Make the queue logically empty.
 int size()
           
 java.lang.Double[] toArray()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Construct the queue.


Queue

public Queue(int size)
Construct the queue.

Parameters:
size - of the queue.
Method Detail

isEmpty

public boolean isEmpty()
Test if the queue is logically empty.

Returns:
true if empty, false otherwise.

makeEmpty

public void makeEmpty()
Make the queue logically empty.


dequeue

public java.lang.Double dequeue()
Return and remove the least recently inserted item from the queue.

Returns:
the least recently inserted item in the queue.

getFront

public java.lang.Double getFront()
Get the least recently inserted item in the queue. Does not alter the queue.

Returns:
the least recently inserted item in the queue.

enqueue

public void enqueue(java.lang.Double x)
Insert a new item into the queue.

Parameters:
x - the item to insert.

size

public int size()
Returns:
amount of elements in the queue.

toArray

public java.lang.Double[] toArray()
Returns:
array of queue (watch out, contains empty cells)